<?php

declare(strict_types = 1);

/**
 * WeEngine System
 *
 * (c) We7Team 2021 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class News extends Model
{
    protected $table = 'ims_w7_demo_tp_wechat_news';
    
    protected $autoWriteTimestamp = 'datetime';
    
    protected $updateTime = false;
    
    protected $field = ['title', 'description', 'label', 'content'];
    
    public function lists(string $label = '')
    {
        return $this->scope(function ($query) use ($label) {
            if (!empty($label)) {
                $query->where('label', $label);
            }
        })->order('id', 'desc')->select();
    }
    
    public function getAllLabel()
    {
        return $this->order('id', 'desc')->field('label')->select();
    }
}
